-
Notifications
You must be signed in to change notification settings - Fork 789
Subscribe support #711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Subscribe support #711
Conversation
|
Hi @ikq, JsSIP code must have the same style in order to make it readable and maintainable. Comments before making a deeper review:
Please take a certain file (ie: RTCSession.js) as a reference and try to stick to its style. |
|
Thanks for the cleanup, 👍 We'll review the PR as we can. |
|
@ikq, Cosmetic comment, we use camelCase in API method arguments (not in 100% of the cases, I know, but we will get there). Could you please make such change? |
jmillan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made the first review.
Please go through all the comments and modify as needed. We'll go for sencond review afterwards.
|
I mostly fixed the issues. [I thought about dialog: About dialog, seems: dialog interface:
other functionality:
It's already implemented in Subscriber/Notifier. |
|
Hi, Super busy lately. Will come back to this when we have some time. |
|
H @ikq,
|
|
Hmm... I just did not consider this possibility before because I found INVITE/CANCEL/ACK specific code and properties in the Dialog (e.g. subscriber used different dialog states set). |
|
There is INVITE related code in Dialog because a dialog for INVITE method needs to behave in certain way, different to generic dialogs, but that's an implementation detail. Other clases should be able to create dialogs the same way RTCSession does. |
|
Hi Jose, I'll continue to test next week:
|
|
Testing of the current version has been completed successfully. |
|
subscribe authentication checked using special test. |
|
I see I should change debug/debugerror to logger... |
|
Hi @ikq, We are super busy lately. Please keep using your branch and update this PR whenever you find any issue/enhancement. Also, tests would accelerate the adoption. |
|
I already use this code for my work and so far no problem. Two browsers test can be taken from: |
|
@ikq, more than an external test I mean tests in JsSIP as part of this PR, testing the clases created here. |
|
Hi, is there some news? I'd like to test this functionality. |
IMHO it's stable code. The subscriber/notifier test can taken from https://github.com/ikq/subscribe_notify_test |
|
Hi, is there a specific reason why Subscriber and Notifier don't use the Contact header from the UA like RTCSession does? If the user provides a custom contact_uri in the UAConfiguration he would have to manually add it as a extra header to Subscriber and Notifier again, wouldn't he? |
I'd like to use the official repository, so I'd like if it will be merged ASAP |
Yes, I'm not using the Configuration.contact_uri In fact, I was in a hurry to do this work, and did not pay attention at all to that there is such a parameter in the configuration ! Let check, how the configuration used for INVITE: Thanks. P.S. |
|
@ikq if you don't mind external contributions i'd be willing to take a swing at writing unit tests for this project's test framework |
Thank you, I will gladly accept your help. I have provided an external test for 2 browsers: one is sending an SUBSCRIBE and the other is receiving it and sending a NOTIFY. Seems in unit test should be simulated 2 instances of JsSIP one send/other receive. |
@ikq Is there a specific reason to use Configuration.contact_uri? Why not just do it as in RTCSession, with |
|
Thank you markusatm for founding the problem. |
|
Hi, Yes, in order for this PR to be merged we need tests in JsSIP project. You don't need two JsSIP instances, just one instance and you should inject a transport that you control (a FAKE transport) that you use to send JsSIP UA SUBSCRIBE|NOTIFY messages and receive and check what comes from JsSIP. If you need some help please let us know. |
|
Hi,
The test SIP sequence is:
The unit test work silently, but if uncomment line JsSIP.debug.enable('JsSIP:*'); SUBSCRIBE and NOTIFY headers checking: |
|
@jmillan We already using it this way :) but it's a bit difficult to maintain separate branch. |
|
I'm not forgetting about this..., |
|
@jmillan Hello! Any chance you had time to review this one? |
|
@jmillan Ping? |
|
For those willing to use this feature I would suggest you use this branch. I don't have at the moment the resources to re-check and merge this, so please, do use this branch for the time being. |
|
Looking forward with this merge also 👍 |
|
@jmillan ping? |
|
Pushed a rebased version in #922. |
|
@ikq thanks for the patience. I'll try 🤞 to finish the review and accept it in the following weeks. Can I ask you to not include any change in |
|
Also please do not edit |
b2ef69c to
d390a7c
Compare
Done |
|
Thanks, I'll take some time on a further, and hopefully last review. |
lib/Notifier.js
Outdated
|
|
||
| if (!subscribe) | ||
| { | ||
| throw new TypeError('subscribe is undefined'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with the code base.
| throw new TypeError('subscribe is undefined'); | |
| throw new TypeError('Not enough arguments. Missing subscribe request'); |
lib/Notifier.js
Outdated
|
|
||
| if (!subscribe.hasHeader('contact')) | ||
| { | ||
| throw new TypeError('subscribe - no contact header'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| throw new TypeError('subscribe - no contact header'); | |
| throw new TypeError('Missing Contact header in subscribe request'); |
lib/Notifier.js
Outdated
|
|
||
| if (!contentType) | ||
| { | ||
| throw new TypeError('contentType is undefined'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| throw new TypeError('contentType is undefined'); | |
| throw new TypeError('Not enough arguments. Missing contentType'); |
lib/Notifier.js
Outdated
| this._expires_timestamp = null; | ||
| this._expires_timer = null; | ||
|
|
||
| // Notifier state: pending, active, terminated. Not used: init, resp_wait. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is unclear to me. What does this mean?:
Not used: init, resp_wait.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably leftovers from a previous iteration.
lib/Notifier.js
Outdated
| this._state = pending ? C.STATE_PENDING : C.STATE_ACTIVE; | ||
|
|
||
| // Custom session empty object for high level use. | ||
| this.data = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, check how in RtcSession.js we use a _data member and then get data() and set data().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| const final_notify_timeout = 30000; | ||
|
|
||
| this._unsubscribe_timeout_timer = setTimeout(() => | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For sanity, check if we are not terminated before calling this._terminateDialog()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is already done inside this._terminateDialog, right at the beginning of the function. Do you find anything missing?
lib/Subscriber.js
Outdated
| STATE_ACTIVE : 1, | ||
| STATE_TERMINATED : 2, | ||
| STATE_INIT : 3, | ||
| STATE_NOTIFY_WAIT : 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| STATE_NOTIFY_WAIT : 4 | |
| STATE_WAITING_NOTIFY : 4 |
lib/Subscriber.js
Outdated
| { | ||
| if (response.status_code >= 200 && response.status_code < 300) | ||
| { | ||
| // Create dialog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a dot at the end of all comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/Subscriber.js
Outdated
|
|
||
| // RFC 6665 3.1.1 subscribe OK response must contain Expires header. | ||
| // Use workaround expires value. | ||
| expires_value = '900'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use the constant value (to be) defined at the top of the file.
lib/Subscriber.js
Outdated
|
|
||
| if (expires_value !== 0 && !expires_value) | ||
| { | ||
| logger.warn('response without Expires header'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| logger.warn('response without Expires header'); | |
| logger.warn('response without Expires header, setting a default value of XYZ'); |
|
Currently UA fires If SUBSCRIBE request does not have a Contact header, the request WONT be responded, hence breaking the SIP protocol. Contact header is verified in Check a similar case in RtcSession: https://github.com/versatica/JsSIP/blob/master/lib/RTCSession.js#L3499 |
|
@orgads, there may be some duplicated suggestion on my review due to a problem between GH and my side, sorry for that. Please simply resolve those duplicated. |
d390a7c to
fb75081
Compare
fb75081 to
9c09c0f
Compare
|
I think all the comments should be now covered. |
|
(I can't Resolve comments since I'm not the owner 🙄) |
I will, no worries. |
I added Subscriber.js Notifier.js to JsSIP
I tried write them according JsSIP style and lint errors.
Please take a look and let me know what needs to be fixed.
I already see that *.d.ts files are missing.
The work still in progress: I want add to SUBSCRIBE Contact +sip.instance
as you do in REGISTER